package studio.raptor.dispatcher.server.controller;


import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import studio.raptor.dispatcher.server.service.GraphService;

/**
 * @author jack
 * @since 1.0
 */
@RestController
@RequestMapping(value = "/event")
public class EventController {

  @Autowired
  GraphService graphService;

  /**
   * 获取可以被发送的事件节点
   *
   * @param code 接口编码
   * @param limit 获取最大值
   */
  @GetMapping(value = "/query")
  public Set<String> query(@RequestParam(value = "code") String code,
      @RequestParam(value = "limit", defaultValue = "30") int limit,
      @RequestParam(value = "status", defaultValue = "w") String status) {
    return graphService.fetchEvent(code, status, limit);
  }

}
